import Vue  from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
    { path: '/',redirect:'/index'},
    {
      path: '/index', 
      component:() => import('../views/index'),
      redirect:'/index/banner',
      meta:{title:'首页'},
      children:[
        { path: 'banner',meta:{title:'轮播图管理'}, component:() => import('../views/shouye/banner')},
        { path: 'category',meta:{title:'分类管理'}, component:() => import('../views/shouye/category')},
        { path: 'recommend',meta:{title:'推荐管理'}, component:() => import('../views/shouye/recommend')},
        { path: 'news',meta:{title:'新闻管理'}, component:() => import('../views/xinwen/news')},
        { path: 'classify',meta:{title:'商品分类管理'}, component:() => import('../views/shangpin/classify')},
        { path: 'brand',meta:{title:'品牌管理'}, component:() => import('../views/shangpin/brand')},
        { path: 'product',meta:{title:'商品管理'}, component:() => import('../views/shangpin/product')}

      ]
    },
    { path: '/login', component:() => import('../views/login')},
  ]
  
  const router = new VueRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    // history: VueRouter.createWebHashHistory(),
    routes// `routes: routes` 的缩写
  })

  // router.beforeEach((to,from,next)=>{
  //   next()
  // })

export default router